package win.larryzeal.jmx.mbean.standard.listener;

import win.larryzeal.jmx.mbean.standard.Hello;

import javax.management.Notification;
import javax.management.NotificationListener;

/**
 * Created by 张少昆 on 2017/8/18 0018.
 */
public class HelloListener implements NotificationListener {
	@Override
	public void handleNotification(Notification notification, Object handback){
		System.out.println("----------HelloListener-Begin------------");
		System.out.println("\ttype = "+ notification.getType());
		System.out.println("\tsource = "+notification.getSource());
		System.out.println("\tseq = "+notification.getSequenceNumber());
		System.out.println("\tsend time = "+notification.getTimeStamp());
		System.out.println("\tmessage="+notification.getMessage());
		System.out.println("----------HelloListener-End------------");

		if (handback != null) {
			if (handback instanceof Hello) { // 这么说的话，其实什么MBean都可以放这里了
				Hello hello = (Hello)handback;
				hello.printHello(notification.getMessage());
			}
		}
	}
}
